package demo10;

/**
 * Created with IntelliJ IDEA.
 * Description:通过方法交换两个数的值(交换实参的值)
 * User: 86183
 */
class MyValue{
    public int value;
}
public class Test {
    public static void swap(MyValue myV1,MyValue myV2){
        int tmp = myV1.value;
        myV1.value = myV2.value;
        myV2.value = tmp;
    }
    public static void main(String[] args) {
        MyValue myValue1 = new MyValue();
        MyValue myValue2 = new MyValue();
        myValue1.value = 10;
        myValue2.value = 20;
        System.out.println("交换之前："+ "myValue1 = "+ myValue1.value+" "+ "myValue2 = "+myValue2.value);
        swap(myValue1,myValue2);
        System.out.println("交换之后："+ "myValue1 = "+ myValue1.value +" "+"myValue2 = "+myValue2.value);

    }
}
